#### Table S18: Multilevel regresssion (Any Denier Candidate) ####

# Libraries
# library(here)
# library(rio)
# library(tidyverse)
# library(lubridate)
# library(stargazer)
# library(lme4)

# data_pnas = import(here("Data","data_pnas.rds"))
deniers_wapo_all = import(here("Data","deniers_wapo_all.rds"))
data_wapo = mutate(data_pnas, any_denier = district %in% deniers_wapo_all)

p_wapo_all1 = lmer(norm_loyaltyre ~ any_denier + (1 | district) + (1 | uid), data = data_wapo, weights = weight)
p_wapo_all2 = lmer(norm_loyaltyre ~ any_denier*pid + (1 | district) + (1 | uid), data = data_wapo, weights = weight)

stargazer(p_wapo_all1, p_wapo_all2,
          title = "Multilevel Regression Results - Any Denier",
          dep.var.labels = "Loyalty",
          column.labels = c("Full","Full"),
          covariate.labels = c("Election Denier Candidate (WaPo)",
                               "Independent",
                               "Republican",
                               "Election Denier (WaPo):Independent",
                               "Election Denier (WaPo):Republican"),
          notes = "Estimated with survey weights and two-sided tests",
          star.cutoffs = c(0.05, 0.01, 0.001),
          omit.stat = c("aic","bic"),
          type = "latex",
          out = here("Tables","Supplementary","table_s18.tex"),
          header = F)

rm(data_wapo, deniers_wapo_all)